#include<iostream>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
#include<cstring>
using namespace std;
const int N = 5e4 + 10;
int a[N];
int n;
unordered_map<int,bool>mp;
int main()
{
	int t;
	scanf("%d", &t);
	while (t--) {
		scanf("%d", &n);
		mp.clear();
		for (int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			if (!mp[a[i]]) {
				cout << a[i] << " ";
				mp[a[i]] = 1;
			}
		}
		cout << endl;
		//memset(a, 0, sizeof(a));
		//s.clear();
		//for (int i = 1; i <= n; i++) {
		//	cin >> a[i];
		//	s.insert(a[i]);
		//}
		///*for (auto x : s) {
		//	cout << x << " ";
		//}
		//cout << endl;*/
		//sort(a + 1, a + n + 1);
		//int cnt = 0;
		//for (int i = 1; i <= n; i++) {
		//	if (i == 1 || a[i] != a[i - 1]) {
		//		a[++cnt] = a[i];
		//	}
		//}
		//for (int i = 1; i <= cnt; i++) {
		//	cout << a[i] << " ";
		//}
		//cout << endl;
	}
	return 0;
}